//Jonathan Flessner
//27-April-2014
//cardTest for village action card
//Smithy = +3 cards
//smithy is card number 13

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

int main(){
	//initialize game
	int seed = time(NULL) % 5000;
	srand(seed);
	struct gameState *gS = malloc(sizeof(struct gameState));
	int k[10] = {adventurer, council_room, feast, gardens, mine , remodel, smithy, village, baron, great_hall};
	int numPlayers = 0;
	int p = 0;				//current player
	
	int hCards = 0;
	
	int tF = 0;				//count of failed tests

	int testNum = 1000;
	int i = 0;

	//run testNum tests
	for(i = 0; i < testNum; i++){
		numPlayers = rand() % 3 + 2;	//2, 3 or 4 players
		initializeGame(numPlayers, k, seed, gS);
		p = rand() % numPlayers;		//pick random player
		
		hCards = rand() % 10;			//highly unlikely ever more than 10 cards in hand
		gS->handCount[p] = hCards;		//set hand count
		
		//call card function or cardEffect
		cardEffect(13, 0, 0, 0, gS, 0, 0);
		
		if(hCards + 2 != gS->handCount[p]){		//note, three cards gained, one card discounted, count add two
			printf("FAIL. Hand Count = %d; Expected Hand Count = %d\n", gS->handCount[p], hCards + 2);
			tF++;
		}
	}
	
	free(gS);
	printf("All tests completed. Tests failed/attempted = %d/%d\n", tF, testNum);
	return 0;
}